package com.inspectortime.webapp.inspector.fee;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.inspectortime.repository.Repository;

public class FeeWizardSelectController implements Controller {
	
	private Repository repository;

	public void setRepository(Repository repository) {
		this.repository = repository;
	}

	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		if (request.getMethod().equalsIgnoreCase("get")) {
			return new ModelAndView("inspector/fee/feeWizardSelect");
		}
		
		String typeStr = request.getParameter("feeWizardType");
		String viewName;
		if (typeStr.equals("basic")) {
			viewName = "basicFlatFeePlan";
		} else if (typeStr.equals("listing")) {
			viewName = "feeWizardListingPrice";
		} else if (typeStr.equals("sqft")) {
			viewName = "feeWizardSqFt";
		} else if (typeStr.equals("bedbath")) {
			viewName = "feeWizardBedBath";
		} else if (typeStr.equals("advanced")) {			
			viewName = "advancedPlan";
		} else {
			throw new RuntimeException("Invalid type: " + typeStr);
		}
		
		ModelAndView mv = new ModelAndView("redirect:" + viewName + ".html");
		return mv;
	}

}
